home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / dpmigcc5.zip / RSX / SOURCE / ASM16 / DPMI10.ASM < prev    next >
Assembly Source File  |  1994-12-12  |  8KB  |  511 lines

  1. ;
  2. ; DPMI10.ASM (c) Rainer Schnitker  '93
  3. ;
  4.  
  5. ;
  6. ; 16bit library for DPMI 0.9 calls
  7. ;
  8. ; define 'HAVE386' to use 32bit DPMI mode
  9. ;
  10.  
  11.     .286
  12.     .model SMALL, C
  13.  
  14. ; macro to call dpmi in ax
  15. ;
  16. DPMI MACRO function
  17.     mov ax,function
  18.     int 31h
  19.     ENDM
  20.  
  21. getdword MACRO high,low,address
  22.     mov low,word ptr address
  23.     mov high,word ptr address.2
  24.     ENDM
  25.  
  26. setdword MACRO address,high,low
  27.     mov word ptr address,low
  28.     mov word ptr address.2,high
  29.     ENDM
  30.  
  31.  
  32.     .data
  33.  
  34.     .code
  35.  
  36.    ;
  37.    ;    int GetMultipleDescriptors(WORD anzahl,WORD *buffer)
  38.    ;
  39.     public    C GetMultipleDescriptors
  40. GetMultipleDescriptors PROC C USES DI, \
  41.     anzahl    :WORD, \
  42.     buffer    :PTR
  43.  
  44.     mov    cx, anzahl
  45.     push    ds
  46.     pop    es
  47. ifdef HAVE386
  48.     .386
  49.     movzx    edi, word ptr buffer
  50.     .286
  51. else
  52.     mov    di, word ptr buffer
  53. endif
  54.     DPMI 000Eh
  55.     jc    short @@end
  56.     xor    ax,ax
  57. @@end:
  58.     ret
  59. GetMultipleDescriptors endp
  60.  
  61.    ;
  62.    ;    int SetMultipleDescriptors(WORD anzahl,WORD *buffer)
  63.    ;
  64.     public    C SetMultipleDescriptors
  65. SetMultipleDescriptors PROC C USES DI, \
  66.     anzahl    :WORD, \
  67.     buffer    :PTR
  68.  
  69.     mov    cx, anzahl
  70.     push    ds
  71.     pop    es
  72. ifdef HAVE386
  73.     .386
  74.     movzx    edi, word ptr buffer
  75.     .286
  76. else
  77.     mov    di, word ptr buffer
  78. endif
  79.     DPMI 000Fh
  80.     jc    short @@end
  81.     xor    ax,ax
  82. @@end:
  83.     ret
  84. SetMultipleDescriptors endp
  85.  
  86.    ;
  87.    ;    int GetProtModeExceptionVector32(BYTE no,WORD *sel,DWORD *off)
  88.    ;
  89.     public    C GetProtModeExceptionVector32
  90. GetProtModeExceptionVector32 PROC C \
  91.     no    :BYTE , \
  92.     segm    :PTR , \
  93.     offs    :PTR
  94.  
  95.     mov    bl,no
  96.     DPMI 0210h
  97.     jc    short @@end
  98.  
  99.     mov    bx,segm
  100.     mov    word ptr [bx],cx
  101.     mov    bx,offs
  102.     mov    word ptr [bx],dx
  103.     .386
  104.     shr    edx,16
  105.     .286
  106.     mov    word ptr [bx].2,dx
  107.  
  108.     xor    ax,ax
  109. @@end:
  110.     ret
  111. GetProtModeExceptionVector32   endp
  112.  
  113.    ;
  114.    ;    int GetRealModeExceptionVector32(BYTE no,WORD *sel,DWORD *off)
  115.    ;
  116.     public    C GetRealModeExceptionVector32
  117. GetRealModeExceptionVector32 PROC C \
  118.     no    :BYTE , \
  119.     segm    :PTR , \
  120.     offs    :PTR
  121.  
  122.     mov    bl,no
  123.     DPMI 0211h
  124.     jc    short @@end
  125.  
  126.     mov    bx,segm
  127.     mov    word ptr [bx],cx
  128.     mov    bx,offs
  129.     mov    word ptr [bx],dx
  130.     .386
  131.     shr    edx,16
  132.     .286
  133.     mov    word ptr [bx].2,dx
  134.     xor    ax,ax
  135. @@end:
  136.     ret
  137. GetRealModeExceptionVector32   endp
  138.  
  139.    ;
  140.    ;    int SetProtModeExceptionVector32(BYTE b,WORD sel,DWORD off)
  141.    ;
  142.     public    C SetProtModeExceptionVector32
  143. SetProtModeExceptionVector32 PROC C \
  144.     b    :BYTE , \
  145.     segm    :WORD , \
  146.     offs    :DWORD
  147.  
  148.     mov    bl,b
  149.     mov    cx,segm
  150.     .386
  151.     mov    edx,offs
  152.     .286
  153.     DPMI 0212h
  154.     jc    short @@end
  155.  
  156.     xor    ax,ax
  157. @@end:
  158.     .386
  159.     xor    edx,edx
  160.     .286
  161.     ret
  162. SetProtModeExceptionVector32   endp
  163.  
  164.    ;
  165.    ;    int SetRealModeExceptionVector32(BYTE b,WORD sel,DWORD off)
  166.    ;
  167.     public    C SetRealModeExceptionVector32
  168. SetRealModeExceptionVector32 PROC C \
  169.     b    :BYTE , \
  170.     segm    :WORD , \
  171.     offs    :DWORD
  172.  
  173.     mov    bl,b
  174.     mov    cx,segm
  175.     .386
  176.     mov    edx,offs
  177.     .286
  178.     DPMI 0213h
  179.     jc    short @@end
  180.  
  181.     xor    ax,ax
  182. @@end:
  183.     .386
  184.     xor    edx,edx
  185.     .286
  186.     ret
  187. SetRealModeExceptionVector32   endp
  188.  
  189.  
  190.    ;
  191.    ;    void GetDPMICapabilities(DPMICAP *v,BYTE *buffer)
  192.    ;
  193.     public    C GetDPMICapabilities
  194. GetDPMICapabilities PROC C USES DI, \
  195.     cap    :WORD, \
  196.     buffer    :WORD
  197.  
  198.     push    ds
  199.     pop    es
  200. ifdef HAVE386
  201.     .386
  202.     movzx    edi, word ptr buffer
  203.     .286
  204. else
  205.     mov    di, word ptr buffer
  206. endif
  207.     DPMI 0401h
  208.     jc    short @@end
  209.     mov    bx, word ptr cap
  210.     mov    word ptr [bx  ],ax
  211.     mov    word ptr [bx+2],cx
  212.     mov    word ptr [bx+4],dx
  213.     xor    ax,ax
  214. @@end:
  215.     ret
  216. GetDPMICapabilities endp
  217.  
  218.  
  219. ifdef HAVE386
  220.    ;
  221.    ;    int AllocLinearMemory(DWORD bytes,DWORD linaddress,DWORD flags,
  222.    ;                  DWORD *handle,DWORD *memaddress)
  223.    ;
  224.     public    C AllocLinearMemory
  225. AllocLinearMemory PROC C \
  226.     nbytes    :DWORD , \
  227.     linaddr :DWORD , \
  228.     flags    :DWORD , \
  229.     handle    :PTR , \
  230.     memadr    :PTR
  231.  
  232.     .386
  233.     push    esi
  234.     mov    ecx, nbytes
  235.     mov    ebx, linaddr
  236.     mov    edx, flags
  237.     DPMI 0504h
  238.     jc    short @@end
  239.  
  240.     movzx    edx, word ptr handle
  241.     mov    dword ptr [edx], esi
  242.     movzx    edx, word ptr memadr
  243.     mov    dword ptr [edx], ebx
  244.     xor    ax, ax
  245. @@end:
  246.     xor    ecx, ecx
  247.     xor    edx, edx
  248.     xor    ebx, ebx
  249.     pop    esi
  250.     .286
  251.  
  252.     ret
  253. AllocLinearMemory  endp
  254.  
  255.    ;
  256.    ;    int ResizeLinearMemory(DWORD bytes,DWORD handle,DWORD flags
  257.    ;                  DWORD *newhandle,DWORD *newmemaddress)
  258.    ;
  259.     public    C ResizeLinearMemory
  260. ResizeLinearMemory PROC C \
  261.     nbytes    :DWORD , \
  262.     handle    :DWORD , \
  263.     flags    :DWORD , \
  264.     new_handle:PTR , \
  265.     new_memadr:PTR
  266.  
  267.     .386
  268.     push    esi
  269.     mov    esi, handle
  270.     mov    ecx, nbytes
  271.     mov    edx, flags
  272.     DPMI 0505h
  273.     jc    short @@end
  274.  
  275.     movzx    edx, word ptr new_handle
  276.     mov    [edx], esi
  277.     movzx    edx, word ptr new_memadr
  278.     mov    [edx], ebx
  279.     xor    ax, ax
  280. @@end:
  281.     xor    ebx, ebx
  282.     xor    ecx, ecx
  283.     pop    esi
  284.     .286
  285.  
  286.     ret
  287. ResizeLinearMemory  endp
  288.  
  289.    ;
  290.    ;    int GetPageAttributes(DWORD handle,DWORD offs,DWORD pages,WORD *attr)
  291.    ;
  292.     public    C GetPageAttributes
  293. GetPageAttributes PROC C \
  294.     handle    :DWORD , \
  295.     offs    :DWORD , \
  296.     pages    :DWORD , \
  297.     attr    :PTR
  298.  
  299.     .386
  300.     push    esi
  301.     push    ebx
  302.     push    ds
  303.     pop    es
  304.     mov    esi, handle
  305.     mov    ebx, offs
  306.     mov    ecx, pages
  307.     movzx    edx, attr
  308.     DPMI 0506h
  309.     jc    short @@end
  310.  
  311.     xor    ax, ax
  312. @@end:
  313.     xor    ecx, ecx
  314.     xor    edx, edx
  315.     pop    ebx
  316.     pop    esi
  317.     .286
  318.  
  319.     ret
  320. GetPageAttributes  endp
  321.  
  322.    ;
  323.    ;    int ModifyPageAttributes(DWORD handle,DWORD offs,DWORD pages,WORD *attr)
  324.    ;
  325.     public    C ModifyPageAttributes
  326. ModifyPageAttributes PROC C \
  327.     handle    :DWORD , \
  328.     offs    :DWORD , \
  329.     npages    :DWORD , \
  330.     attr    :PTR
  331.  
  332.     .386
  333.     push    esi
  334.     push    ebx
  335.     push    ds
  336.     pop    es
  337.     mov    esi, handle
  338.     mov    ebx, offs
  339.     mov    ecx, npages
  340.     movzx    edx, word ptr attr
  341.     DPMI 0507h
  342.     jc    short @@end
  343.  
  344.     xor    ax, ax
  345. @@end:
  346.     xor    ecx, ecx
  347.     xor    edx, edx
  348.     pop    ebx
  349.     pop    esi
  350.     .286
  351.  
  352.     ret
  353. ModifyPageAttributes  endp
  354.  
  355.    ;
  356.    ;    int MapDeviceInMemoryBlock(DWORD handle,DWORD offs,
  357.    ;                   DWORD pages,DWORD device)
  358.    ;
  359.     public    C MapDeviceInMemoryBlock
  360. MapDeviceInMemoryBlock PROC C \
  361.     handle    :DWORD , \
  362.     offs    :DWORD , \
  363.     pages    :DWORD , \
  364.     device    :DWORD
  365.  
  366.     .386
  367.     push    esi
  368.     push    ebx
  369.     mov    esi, handle
  370.     mov    ebx, offs
  371.     mov    ecx, pages
  372.     mov    edx, device
  373.     DPMI 0508h
  374.     jc    short @@end
  375.  
  376.     xor    ax, ax
  377. @@end:
  378.     xor    ecx, ecx
  379.     xor    edx, edx
  380.     pop    ebx
  381.     pop    esi
  382.     .286
  383.  
  384.     ret
  385. MapDeviceInMemoryBlock    endp
  386.  
  387.    ;
  388.    ;    int MapDOSMemInMemoryBlock(DWORD handle,DWORD offs,
  389.    ;                   DWORD pages,DWORD dosmem)
  390.    ;
  391.     public    C MapDOSMemInMemoryBlock
  392. MapDOSMemInMemoryBlock PROC C \
  393.     handle    :DWORD , \
  394.     offs    :DWORD , \
  395.     pages    :DWORD , \
  396.     dosmem    :DWORD
  397.  
  398.     .386
  399.     push    esi
  400.     push    ebx
  401.     mov    esi, handle
  402.     mov    ebx, offs
  403.     mov    ecx, pages
  404.     mov    edx, dosmem
  405.     DPMI 0509h
  406.     jc    short @@end
  407.  
  408.     xor    ax, ax
  409. @@end:
  410.     xor    ecx, ecx
  411.     xor    edx, edx
  412.     pop    ebx
  413.     pop    esi
  414.     .286
  415.     ret
  416. MapDOSMemInMemoryBlock    endp
  417.  
  418. endif    ;HAVE386
  419.  
  420.  
  421.    ;
  422.    ;    int GetMemoryBlockData(DWORD handle,DWORD *addr,DWORD *bytes)
  423.    ;
  424.     public    C GetMemoryBlockData
  425. GetMemoryBlockData PROC C USES DI SI, \
  426.     handle    :DWORD , \
  427.     addr    :PTR , \
  428.     bytes    :PTR
  429.  
  430.     getdword si,di,handle
  431.     DPMI 050Ah
  432.     jc    short @@end
  433.     mov    bx, addr
  434.     setdword [bx],bx,dx
  435.     mov    bx, bytes
  436.     setdword [bx],si,di
  437.     xor    ax, ax
  438. @@end:
  439.  
  440.     ret
  441. GetMemoryBlockData  endp
  442.  
  443.    ;
  444.    ;    int GetMemoryInfo(INFO *info)
  445.    ;
  446.     public    C GetMemoryInfo
  447. GetMemoryInfo PROC C USES DI, \
  448.     info    :WORD
  449.  
  450.     push    ds
  451.     pop    es
  452. ; ifdef HAVE386
  453.     .386
  454.     movzx    edi, word ptr info
  455.     .286
  456. ; endif
  457.     DPMI 050Bh
  458.     jc    short @@end
  459.     xor    ax, ax
  460. @@end:
  461.     ret
  462. GetMemoryInfo  endp
  463.  
  464.    ;
  465.    ;    int FreePhysicalMapping(DWORD address)
  466.    ;
  467.     public    C FreePhysicalMapping
  468. FreePhysicalMapping PROC C \
  469.     address :DWORD
  470.  
  471.     getdword bx,cx,address
  472.     DPMI 0801h
  473.     jc    short @@end
  474.     xor    ax, ax
  475. @@end:
  476.     ret
  477. FreePhysicalMapping  endp
  478.  
  479.    ;
  480.    ;    int DpmiGetCoproStatus(UINT *status)
  481.    ;
  482.     public DpmiGetCoproStatus
  483. DpmiGetCoproStatus PROC C \
  484.     status    :PTR
  485.     DPMI 0E00h
  486.     jc    short @@end
  487.     mov    bx, status
  488.     mov    word ptr [bx], ax
  489.     xor    ax, ax
  490. @@end:
  491.     ret
  492. DpmiGetCoproStatus endp
  493.  
  494.  
  495.    ;
  496.    ;    int DpmiSetCoproStatus(UINT status)
  497.    ;
  498.     public DpmiSetCoproStatus
  499. DpmiSetCoproStatus PROC C \
  500.     bits    :WORD
  501.  
  502.     mov    bx, bits
  503.     DPMI 0E01h
  504.     jc    short @@end
  505.     xor    ax, ax
  506. @@end:
  507.     ret
  508. DpmiSetCoproStatus endp
  509.  
  510.     end
  511.